package com.atguigu.gmall.pay.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.atguigu.gmall.pay.properties.AliPayProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AlipayConfiguration {

    @Autowired
    private AliPayProperties aliPayProperties ;

    @Bean
    public AlipayClient alipayClient() {

        AlipayClient alipayClient = new DefaultAlipayClient(aliPayProperties.getGateway() , aliPayProperties.getAppId() ,
                aliPayProperties.getPrivateKey() ,
                aliPayProperties.getFormat() , aliPayProperties.getCharset() , aliPayProperties.getPublicKey() ,
                aliPayProperties.getSignType()) ;


        return alipayClient ;

    }

}
